package com.guigu.www.controller;
import com.guigu.www.pojo.Authorization;
import com.guigu.www.pojo.Roles;
import com.guigu.www.service.AuthorizationService;
import com.guigu.www.service.RoleAuthorizationService;
import com.guigu.www.service.RolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class RoleAuthorizationController {
    //获取service
    @Autowired
    RoleAuthorizationService service;
    @Autowired
    AuthorizationService authorizationService;
    @Autowired
    RolesService rolesService;
    @PostMapping("addquanxian.action")
    public Map addquanxian(@RequestBody Roles roles){
        System.out.println(roles);
        service.addquanxian2(roles);
        Map map=new HashMap();
        map.put("msg","赋予成功");
        return map;
    }
    @RequestMapping("querybyauall.action/{roleid}")
    public Roles querybyauall(@PathVariable int roleid){
        Roles roles=rolesService.getById(roleid);
        List<Authorization> authorizationList=service.addquanxian(roleid);
        roles.setAuthorizationList(authorizationList);
        return roles;
    }
}
